package com.xzh.entity;

import java.util.Scanner;

public class Consumer {
    private Scanner sc = new Scanner(System.in);
    private Fruit fruit=new Fruit();

    public void setFruit(Fruit fruit) {
        this.fruit = fruit;
    }

    public void buyFruit() {
        System.out.println("请输入你要购买的水果：");
        String a = sc.next();
        switch (a) {
            case "香蕉":
                fruit.setFruity("香蕉味");
                break;
            case "苹果":
                fruit.setFruity("苹果味");
                break;
            case "西瓜":
                fruit.setFruity("西瓜味");
                break;
            case "梨":
                fruit.setFruity("梨味");
                break;
            default:
                System.out.println("没有购买到该水果");
        }
        fruit.setFruitName(a);
    }
    public void eatFruit(){
        System.out.println(fruit.getFruitName()+"的味道为："+fruit.getFruity());
    }
}
